package com.ruoyi.web.controller.system;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ImportantReminder;
import com.ruoyi.system.service.IImportantReminderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 要事提醒
Controller
 * 
 * @author ruoyi
 * @date 2022-04-18
 */
@RestController
@RequestMapping("/system/reminder")
@Api(tags = "要事提醒")
public class ImportantReminderController extends BaseController
{
    @Autowired
    private IImportantReminderService importantReminderService;

    /**
     * 查询要事提醒
列表
     */
    @PreAuthorize("@ss.hasPermi('system:reminder:list')")
    @GetMapping("/list")
    public TableDataInfo list(ImportantReminder importantReminder)
    {
        startPage();
        List<ImportantReminder> list = importantReminderService.selectImportantReminderList(importantReminder);
        return getDataTable(list);
    }

    /**
     * 导出要事提醒
列表
     */
    @PreAuthorize("@ss.hasPermi('system:reminder:export')")
    @Log(title = "要事提醒 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ImportantReminder importantReminder)
    {
        List<ImportantReminder> list = importantReminderService.selectImportantReminderList(importantReminder);
        ExcelUtil<ImportantReminder> util = new ExcelUtil<ImportantReminder>(ImportantReminder.class);
        return util.exportExcel(list, "要事提醒数据");
    }

    /**
     * 获取要事提醒
详细信息
     */
    @ApiOperation(value = "获取要事提醒详细信息")
    @PreAuthorize("@ss.hasPermi('system:reminder:query')")
    @GetMapping()
    public AjaxResult getInfo()
    {

        return AjaxResult.success(importantReminderService.selectImportantReminderById());
    }

    /**
     * 新增要事提醒

     */
    @ApiOperation(value = "新增要事提醒")
    @PreAuthorize("@ss.hasPermi('system:reminder:add')")
    @Log(title = "要事提醒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add()
    {
        return toAjax(importantReminderService.insertImportantReminder());
    }

    /**
     * 修改要事提醒

     */
    @PreAuthorize("@ss.hasPermi('system:reminder:edit')")
    @Log(title = "要事提醒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImportantReminder importantReminder)
    {
        return toAjax(importantReminderService.updateImportantReminder(importantReminder));
    }

    /**
     * 删除要事提醒

     */
    @PreAuthorize("@ss.hasPermi('system:reminder:remove')")
    @Log(title = "要事提醒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(importantReminderService.deleteImportantReminderByIds(ids));
    }
}
